#!/usr/bin/env python3
from json import load
from os.path import join, dirname, abspath

CPI = {}


def main():
    with open(join(dirname(abspath(__file__)), "fredgraph.json")) as fredgraph:
        fredgraph = load(fredgraph)
        year, month = fredgraph[-1][0].split("-")
        for y,r in fredgraph:
            if y.endswith("-"+month):
                CPI[int(y.split("-")[0])] = float(r)



main()
